package com.foreknow.elm.controller;

import com.foreknow.elm.service.OrderService;
import com.foreknow.elm.service.impl.OrderServiceImpl;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 啊滨
 * @date 2023/2/15 15:44
 */
public class OrderController {
    public Object createOrders(HttpServletRequest request){
        String userId = request.getParameter("userId");
        int businessId = Integer.parseInt(request.getParameter("businessId"));
        int daId = Integer.parseInt(request.getParameter("daId"));
        double orderTotal = Double.parseDouble(request.getParameter("orderTotal"));
        OrderService service=new OrderServiceImpl();
        return service.createOrders(userId,businessId,daId,orderTotal);
    }

    public Object getOrdersById(HttpServletRequest request) {
        int orderId = Integer.parseInt(request.getParameter("orderId"));
        OrderService service = new OrderServiceImpl();
        return service.getOrdersById(orderId);
    }

    public Object listOrdersByUserId(HttpServletRequest request) {
        String userId = request.getParameter("userId");
        OrderService service = new OrderServiceImpl();
        return service.listOrdersByUserId(userId);
    }
}
